from selenium import webdriver
from selenium.webdriver.common.by import By
import time

# 打开edge浏览器
driver = webdriver.Edge()
# driver = webdriver.Firefox()
# driver = webdriver.Chrome()
# 进入126邮箱网站
driver.get('https://www.126.com/')
driver.maximize_window()
time.sleep(5)
# xpath定位账号输入框
driver.find_element(By.XPATH, '//*[@id="auto-id-1748918968570"]').send_keys('ll1234560603')
time.sleep(2)
# class定位账号输入框
driver.find_element(By.CLASS_NAME, 'j-inputtext dlpwd').send_keys('lj070130.')
time.sleep(2)
# id定位登录按钮
driver.find_element(By.ID, 'dologin').click()
time.sleep(3)
# 使用selector定位写信
driver.find_element(By.CSS_SELECTOR, '#_mail_component_98_98 > span.oz0').click()
time.sleep(3)
# xpath定位收件人
driver.find_element(By.XPATH, '/html/body/div[2]/div[1]/div[5]/div[1]/section/header/div[1]/div[1]/div/div[2]').send_keys('15523615751@163.com')
time.sleep(2)
# xpath定位发送
driver.find_element(By.XPATH, '/html/body/div[2]/div[1]/div[5]/header/div/div[1]/div/span[2]').click()
time.sleep(2)
# xpath定位确定按钮
driver.find_element(By.XPATH, '/html/body/div[12]/div[3]/div[2]/div[1]/span').click()
time.sleep(2)